<?php

namespace App\Model;

use Illuminate\Database\Eloquent\Model;

class Download extends Model
{
    //
    protected $table = "ecms_download";
    public function getTitleurlAttribute($value) {
        return $value = env('APP_URL'). "/soft/".$this->id.'.html';
    }
    public function getTitlepicAttribute($value) {
        if ($value != '') {
            if(!isset(parse_url($value)['host'])) {
                return env('IMG_URL') . $value;
            }
        } else {
            return env('IMG_URL') . "/d/file/404.jpg";
        }
    }
    public function getSoftsayAttribute($value) {
        $value = stripslashes($value);
        $value = str_replace('src="/d/file/', 'src="'.env('IMG_URL').'/d/file/', $value);
        return $value;

    }
    public function getNewsTimeAttribute($value) {
        return date("y-m-d",$value);
    }
}
